Skip to content

Wireless support - fine tuning#2002

Merged
limetech merged 1 commit into
unraid:masterfrom
bergware:master
Feb 7, 2025
Merged

Wireless support - fine tuning#2002
limetech merged 1 commit into
unraid:masterfrom
bergware:master

Conversation

@bergware

@bergware bergware commented Feb 7, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Extended wireless network integration across Docker and VM settings, including explicit wireless labeling.
    • Introduced a virtual interface mechanism to enhance wireless connectivity stability.
  • Enhancements
    • Refined network description logic to ensure clear and accurate naming of network options.
    • Streamlined configuration screens, offering increased flexibility by enabling all network options for virtual machines.
    • Improved network port selection, ensuring optimal handling of both wired and wireless interfaces.

@coderabbitai

coderabbitai Bot commented Feb 7, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update refines network interface management across multiple components. The Docker management files now include logic for wireless interfaces alongside wired ones, with new helper functions to conditionally render UI elements. The network name generation has been improved and method signatures standardized. In addition, the VM form now allows all network options without disabling any, and the system startup scripts incorporate wireless support by updating interface detection, route addition, and virtual link management.

Changes

File(s) Change Summary
emhttp/plugins/dynamix.docker.manager/DockerSettings.page, emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php, emhttp/plugins/dynamix.docker.manager/include/DockerClient.php Enhanced Docker network configuration: included wlan interfaces in checks, added hide_wlan and hide_eth functions, updated network description conditions, and standardized method signature formatting.
emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php Removed conditional disabling of network options, allowing all VM network types to be selectable.
etc/rc.d/rc.docker, etc/rc.d/rc.wireless Updated system scripts to recognize wireless interfaces: modified interface detection logic, added virtual wireless link management, and standardized command execution.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant UI as DockerSettings.page
    participant Helper as Helper Functions (hide_wlan/hide_eth)
    participant DockerUtil as DockerClient.php

    User ->> UI: Request Docker settings page
    UI ->> UI: Gather network interfaces (bond, eth, wlan)
    UI ->> Helper: Check interface type (wlan vs. others)
    Helper -->> UI: Return visibility status
    UI ->> DockerUtil: Validate network port (using mgmt_port & lan_port)
    DockerUtil -->> UI: Provide port configuration
    UI ->> User: Render updated network UI
Loading
sequenceDiagram
    participant System as Startup Script (rc.docker)
    participant Wireless as rc.wireless

    System ->> System: Detect available interfaces (eth and wlan)
    System ->> Wireless: Check and create virtual wireless link (LINK)
    Wireless ->> Wireless: Bring up primary interface and virtual LINK
    Wireless ->> System: Execute standardized wireless startup commands
    System ->> Wireless: Update container routes for wlan0
Loading

Possibly related PRs

Poem

Oh, I’m a rabbit, hopping free,
Updating networks with glee,
Wired, wireless, all in view,
New functions shine, crisp and true,
With each change I softly cheer—
🐇 Code and networks, now all clear!
Hoppy days for every gear!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
etc/rc.d/rc.wireless (1)

217-219: Use safer cleanup approach for wireless stop.

The current implementation uses pkill which might be too aggressive. Consider using killall with specific process name or pidof to ensure only the intended process is terminated.

-    run pkill wpa_supplicant
+    if pid=$(pidof wpa_supplicant); then
+        run kill $pid
+    fi
etc/rc.d/rc.docker (1)

510-512: Enhance cleanup of wireless network interfaces.

The cleanup of wireless network interfaces should be more thorough to prevent resource leaks.

-        [[ -e $SYSTEM/$NETWORK ]] && run ip addr flush dev $NETWORK
+        if [[ -e $SYSTEM/$NETWORK ]]; then
+            run ip addr flush dev $NETWORK
+            run ip link set $NETWORK down
+        fi
emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php (1)

1099-1100: LGTM with a minor formatting suggestion.

The wireless interface detection is correctly implemented and properly internationalized. However, there's a minor formatting inconsistency.

Consider standardizing the spacing after -- to match other conditions:

-    $name .= '  -- '._('Wireless interface');
+    $name .= ' -- '._('Wireless interface');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e10f94 and 94d1ee6.

📒 Files selected for processing (6)
  • emhttp/plugins/dynamix.docker.manager/DockerSettings.page (14 hunks)
  • emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php (1 hunks)
  • emhttp/plugins/dynamix.docker.manager/include/DockerClient.php (3 hunks)
  • emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php (0 hunks)
  • etc/rc.d/rc.docker (11 hunks)
  • etc/rc.d/rc.wireless (3 hunks)
💤 Files with no reviewable changes (1)
  • emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
🔇 Additional comments (9)
etc/rc.d/rc.docker (2)

19-21: LGTM! Network interface types properly updated.

The script now correctly includes wireless interfaces in the stock network types and network interface detection.


411-416: Verify virtual interface handling for wireless networks.

The script creates a shim interface for wireless networks, but we should verify that the interface naming doesn't conflict with existing interfaces.

emhttp/plugins/dynamix.docker.manager/DockerSettings.page (3)

116-118: LGTM! Well-designed wireless interface visibility check.

The hide_wlan function properly checks for wireless interface visibility based on management port status.


120-123: LGTM! Ethernet interface visibility management.

The hide_eth function correctly handles the visibility of ethernet interfaces when wireless is the primary interface.


312-362: Verify UI state consistency.

The UI visibility logic for network interfaces should maintain consistency across page reloads and Docker service restarts.

emhttp/plugins/dynamix.docker.manager/include/DockerClient.php (3)

43-43: LGTM! Clear management port definition.

The management port array is well-defined and includes all necessary interface types.


1084-1121: LGTM! Improved method signature formatting.

The method signatures are now consistently formatted and maintain proper return type declarations.


46-47: Verify port selection logic for edge cases.

The port selection logic should be tested with various network configurations to ensure proper fallback behavior.

emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php (1)

1095-1095: LGTM! Improved robustness in description handling.

The change from direct boolean evaluation to empty() check makes the code more robust by properly handling all falsy values.

Comment thread etc/rc.d/rc.wireless
Comment on lines +242 to +245
run iw dev $PORT connect "$SSID" auth open
elif [[ $SECURITY =~ "WEP" ]]; then
# WEP encryption
iw dev $PORT connect "$SSID" auth shared key 0:$(hex "$PASSWORD") 2>/dev/null
run iw dev $PORT connect "$SSID" auth shared key 0:$(hex "$PASSWORD")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance error handling for network connection.

The network connection commands lack error handling and timeout mechanisms. This could lead to indefinite waits if the network is unreachable.

-    run iw dev $PORT connect "$SSID" auth open
+    if ! timeout 30 iw dev $PORT connect "$SSID" auth open; then
+        log "Failed to connect to open network $SSID"
+        return 1
+    fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run iw dev $PORT connect "$SSID" auth open
elif [[ $SECURITY =~ "WEP" ]]; then
# WEP encryption
iw dev $PORT connect "$SSID" auth shared key 0:$(hex "$PASSWORD") 2>/dev/null
run iw dev $PORT connect "$SSID" auth shared key 0:$(hex "$PASSWORD")
if ! timeout 30 iw dev $PORT connect "$SSID" auth open; then
log "Failed to connect to open network $SSID"
return 1
fi
elif [[ $SECURITY =~ "WEP" ]]; then
# WEP encryption
run iw dev $PORT connect "$SSID" auth shared key 0:$(hex "$PASSWORD")

Comment thread etc/rc.d/rc.wireless
Comment on lines +182 to +183
LINK=shim-$PORT
[[ -e $SYSTEM/$LINK ]] || run ip link add link $PORT name $LINK type ipvlan mode l2 bridge

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify virtual link creation for wireless interface.

The script creates a virtual link using ipvlan in bridge mode. This is a good approach for integrating wireless interfaces with Docker networking, but we should ensure the link is properly cleaned up when stopping the wireless interface.


🏁 Script executed:

#!/bin/bash
# Description: Check if shim interface is properly cleaned up on wireless stop
# Test: Search for any leftover shim interfaces
ip link show | grep -P '^shim-wlan'

Length of output: 130


🏁 Script executed:

#!/bin/bash
# Script to search for any commands that might clean up the virtual "shim" interface
echo "=== Searching for commands that delete a shim interface ==="
grep -R "ip link delete" etc/rc.d/rc.wireless || echo "No 'ip link delete' commands found."

echo ""
echo "=== Searching for shutdown/stop sections that may include cleanup ==="
grep -R "stop)" etc/rc.d/rc.wireless || echo "No 'stop' cases found in the script."

echo ""
echo "=== Searching for any cleanup-related functions with 'cleanup' keyword ==="
grep -R "cleanup" etc/rc.d/rc.wireless || echo "No 'cleanup' functions or references found."

Length of output: 869


Issue: Missing cleanup for virtual interface shim created with ipvlan.

Our review of the wireless management script (etc/rc.d/rc.wireless) confirms that while the code creates a virtual link with:

  LINK=shim-$PORT
  [[ -e $SYSTEM/$LINK ]] || run ip link add link $PORT name $LINK type ipvlan mode l2 bridge

no corresponding cleanup is implemented. Searches for commands like “ip link delete”, references to “stop)” in the script, or any “cleanup” functions yielded no results. This indicates that the virtual interface is not properly removed when the wireless interface is stopped.

  • Ensure cleanup logic is added (for example, within the wireless stop routine) to delete the shim interface, e.g., using "ip link delete $LINK".
  • Verify that this cleanup action is coordinated with other network interface management routines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants